/**
 * 
 */
var start = false;
var ctx;
var startX=0, startY=0;
function drawinginit()
{
	document.getElementById('canvas').onmousemove = lto;
	document.getElementById('canvas').onclick = set;
	ctx = document.getElementById('canvas').getContext('2d');
}
function lto(ev)
{
	var d = document.getElementById('result');
	var x = ev.clientX-10;
	var y = ev.clientY-9;
	d.innerHTML = 'x='+x+', y='+y;
	if(start)
	{
		ctx.lineTo(x,y);
		ctx.stroke();
	}
}
function set(ev)
{
	start =!start;
	startX = ev.clientX-10;
	startY = ev.clientY-9;
	//선그리기 시작점 설정
	if(start)
	{
		ctx.beginPath();
		ctx.moveTo(startX,startY);
		lc = document.getElementById('linecolor');
		lw = document.getElementById('linewidth');
		ctx.lineWidth = lw.value;
		ctx.strokeStyle=lc.value;
	}
	else
	{
		ctx.closePath();
	}
}